/*
*    Qizx/open 3.0 beta
*
* This code is the open-source version of Qizx.
* Copyright (C) 2004-2009 Axyana Software -- All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License 
*  Version 1.1 (the "License"); you may not use this file except in 
*  compliance with the License. You may obtain a copy of the License at
*  http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
*  WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
*  for the specific language governing rights and limitations under the
*  License.
*
* The Initial Developer of the Original Code is Xavier Franc - Axyana Software.
*
*/
using System;
using EvaluationException = System.Qizx.Api.EvaluationException;
using Item = System.Qizx.Api.Item;
using XQDate = System.Qizx.Api.Util.XQDate;
using XQDateTime = System.Qizx.Api.Util.XQDateTime;
using XQDateTimeBase = System.Qizx.Api.Util.XQDateTimeBase;
using DateTimeException = System.Qizx.Api.Util.XQDateTimeException;
using Duration = System.Qizx.Api.Util.XQDuration;
using BasicNode = System.Qizx.Xdm.BasicNode;
namespace System.Qizx.XQuery {

    /// <summary> XQuery abstract Item representation.
    /// <p>
    /// The type of the item (XQItemType) is returned by method getType().
    /// <p>
    /// Specialized methods getXXX() allow to retrieve or convert the actual item
    /// value according to the type. An exception (XQTypeException) is raised if the
    /// conversion is not possible.
    /// </summary>
    public struct XQItemCompareType {
        public readonly static int COMPAR_ORDER = 1; // for lt gt le ge
        public readonly static int COMPAR_VALUE = 2;
    }
    public interface XQItem : Item {
        /// <summary> Gets the item as a Duration value.</summary>
        Duration Duration {
            get;

        }
        /// <summary> Gets the item as a Duration value.</summary>
        XQDateTimeBase ValueAsMoment {
            get;

        }
        /// <summary> Specialized cast from string, used for node value conversion, possibly
        /// using Indexing rules.
        /// </summary>
        XQDate ValueAsDate {
            get;

        }
        /// <summary> Specialized cast from string, used for node value conversion, possibly
        /// using Indexing rules.
        /// </summary>
        XQDateTime ValueAsDateTime {
            get;

        }
        XQItemType ItemType {
            get;

        }

        BasicNode GetBasicNode();

        /// <summary> Compares two items.
        /// 
        /// </summary>
        /// <param name="flags">bitwise combination of flags for special comparisons:
        /// COMPAR_ORDER, COMPAR_VALUE
        /// </param>
        /// <returns> EQ GT LT COMPAR_ERROR or COMPAR_FAIL
        /// </returns>
        int CompareTo(XQItem that, ComparisonContext context, int flags);

        /// <summary> Deep equality of two items.
        /// 
        /// </summary>
        /// <throws>  EvaluationException </throws>
        bool DeepEquals(XQItem item, ComparisonContext context);
    }
}